home *** CD-ROM | disk | FTP | other *** search
- Path: informix.com!news
- From: Daniel Wood <dwood>
- Newsgroups: comp.std.c
- Subject: Undefined result vs. int's holding undefined values.
- Date: 5 Jan 1996 21:59:39 GMT
- Organization: Informix Software, Inc. Menlo Park, CA 94025
- Message-ID: <4ck70b$rd7@news.informix.com>
- NNTP-Posting-Host: dwood.informix.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
- X-URL: news:comp.std.c
-
- THE TEST CASE, on SCO:
-
- main() { f(-2147483647, 1879048192); }
-
- f(int x, int y) {
- int r;
-
- if ((r=(x-y)) > 0)
- printf("1: r greater than 0\n");
-
- if (r > 0)
- printf("2: r greater than 0\n");
- }
-
- On SCO only the second print occurs. The reason given to me is that ANSI
- states
- that the result of an overflowing/underflowing operation is undefined. The
- implementation is free to do what it wants with the result. This is fine
- with me, however int's, unlike floats, have NO undefined bit patterns and
- no matter what you do with the undefined result(Scramble the bits for all
- I care) once you store that something into an int variable that int
- is NOT undefined and allowed to exhibit volatile behavior.
-
- Saying a result is undefined "IS NOT EQUAL TO" saying that a C int variable
- can actually hold an undefined value. If you think the test case is running
- acceptably, as described above, then tell me the section of the standard that
- states or implies that an int variable can hold an undefined value.
-
- Why say ye all?
-
- --
- If you want a fancy saying then go find yourself a poet.
- If you want a bug cracked then you've come to the right place.
-
- "The numbers speak to me" - 44 61 6E 20 57 6F 6F 64
-
-